﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FindAnything.OpenAPI;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Xaml.Media.Imaging;

namespace FindAnything
{

    public sealed partial class LostList : Page
    {
        XmlParsing Parser;
        LostCenter lost;
        String state;

        public LostList()
        {
            this.InitializeComponent();
            Parser = new XmlParsing();
            lost = new LostCenter();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            this.state = e.Parameter.ToString();
            String []info = e.Parameter.ToString().Split(',');
            String line = info[0];
            String sdate = info[1];
            String edate = info[2];
            String cate = info[3];

            lost.Center(line);
            BitmapImage bi = new BitmapImage();
            bi.UriSource = new Uri(lost.GET_IMG_URL());
            center_img.Source = bi;
            Info1.Text = lost.GET_DESC();

            ItemView.ItemsSource = Parser.all_Item(line,sdate,edate,cate);

        }

        void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item = ((Item)e.ClickedItem);
            this.Frame.Navigate(typeof(ItemDetailView), item);
        }

        private void GoBack(object sender, RoutedEventArgs e)
        {
            if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack();
        }

    }
}
